package com.app.web.sys.icon;

import com.app.utils.base.http.ResultUtil;
import com.app.utils.spring.properties.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description 图标服务
 * @author zhangmijia
 * @date 2019-05-05
 */
@RestController
@RequestMapping("/system/icon/")
public class IconController {

	@Autowired
	private IconManager iconManager;

	/**
	 * 图标信息接口
	 * @param placeId 图标展示地方：1、个人中心，2、会员中心，3、会员中心，4、首页广告
	 * @return
	 */
	@ResponseBody
	@RequestMapping("info")
	public String info(@RequestParam(defaultValue = "0") int placeId,
					   @RequestParam(defaultValue = "0") int app,
					   @RequestParam(defaultValue = "0") int role,
//					   @RequestAttribute int uid,
					   @RequestParam(defaultValue = "0") int appVersion
	){
		//验证参数
		if(placeId <= 0 || app <= 0){
			ResultUtil.error("6001", Config.pp.get("6001"));
		}
		app = app > 5 ? 5 : app;
		//通过 位置 端 角色 返回图标
		return iconManager.infoByRole(placeId, app, role, appVersion);
	}

}
